import callback from '../function/callback'
import isArrayLike from '../util/isArrayLike'

function some(obj, predicate, context) {
  predicate = callback(predicate, context)
  const keys = !isArrayLike(obj) && Object.keys(obj)
  const length = (keys || obj).length

  for (let i = 0; i < length; i++) {
    const currentKey = keys ? keys[i] : i
    if (predicate(obj[currentKey], currentKey, obj)) {
      return true
    }
  }

  return false
}

export default some
